package cn.lijiancn01.demo.system.convert;

import cn.lijiancn01.demo.system.codegen.MyCustomConfig;
import cn.lijiancn01.demo.system.codegen.MyFreemarkerTemplate;
import cn.lijiancn01.demo.system.codegen.MyJavaFileGenerator;
import cn.lijiancn01.demo.system.codegen.MyTemplate;
import cn.lijiancn01.demo.system.vo.TemplateVO;
import org.apache.commons.lang3.StringUtils;

public class MyCustomConfigConvert {
    //模板类型
    public static final MyTemplate myTemplate = new MyFreemarkerTemplate();

    public static MyCustomConfig of(TemplateVO templateVO) {
        return new MyCustomConfig()
                .setCode(templateVO.getCode())
                .setPackagePath(StringUtils.defaultString(templateVO.getPackagePath()))
                .setClassPrefix(StringUtils.defaultString(templateVO.getClassPrefix()))
                .setClassSuffix(StringUtils.defaultString(templateVO.getClassSuffix()))
                .setMyTemplate(myTemplate)
                .setGenerator(new MyJavaFileGenerator(templateVO.getCode()))
                .setContent(StringUtils.defaultString(templateVO.getContent()));
    }
}
